package com.huitone.smspfm.interfacz.core;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import com.bin.common.utils.FileUtils;
import com.bin.common.utils.StringUtils;
import com.huitone.smspfm.context.utils.ContextPropertiesUtils;
import com.huitone.smspfm.context.utils.ContextUtils;
import com.huitone.smspfm.interfacz.dao.ErrorMngMapper;
import com.huitone.smspfm.interfacz.dao.ForbidRuleMapper;
import com.huitone.smspfm.interfacz.dao.GateDefMapper;
import com.huitone.smspfm.interfacz.dao.MoInsMapper;
import com.huitone.smspfm.interfacz.dao.PlatformServerMapper;
import com.huitone.smspfm.interfacz.dao.ReduserListMapper;
import com.huitone.smspfm.interfacz.dao.SmsResultCodeDefMapper;
import com.huitone.smspfm.interfacz.dao.SpeedControlMapper;
import com.huitone.smspfm.interfacz.dao.SvrNodeCodeRltMapper;
import com.huitone.smspfm.interfacz.dao.SvrNodeDefMapper;
import com.huitone.smspfm.interfacz.dao.UserRouteRuleMapper;
import com.huitone.smspfm.interfacz.dao.entity.ErrorMng;
import com.huitone.smspfm.interfacz.dao.entity.ErrorMngExample;
import com.huitone.smspfm.interfacz.dao.entity.ForbidRule;
import com.huitone.smspfm.interfacz.dao.entity.ForbidRuleExample;
import com.huitone.smspfm.interfacz.dao.entity.GateDef;
import com.huitone.smspfm.interfacz.dao.entity.GateDefExample;
import com.huitone.smspfm.interfacz.dao.entity.MoIns;
import com.huitone.smspfm.interfacz.dao.entity.MoInsExample;
import com.huitone.smspfm.interfacz.dao.entity.PlatformServer;
import com.huitone.smspfm.interfacz.dao.entity.PlatformServerExample;
import com.huitone.smspfm.interfacz.dao.entity.ReduserList;
import com.huitone.smspfm.interfacz.dao.entity.ReduserListExample;
import com.huitone.smspfm.interfacz.dao.entity.SmsResultCodeDef;
import com.huitone.smspfm.interfacz.dao.entity.SmsResultCodeDefExample;
import com.huitone.smspfm.interfacz.dao.entity.SpeedControl;
import com.huitone.smspfm.interfacz.dao.entity.SpeedControlExample;
import com.huitone.smspfm.interfacz.dao.entity.SvrNodeCodeRlt;
import com.huitone.smspfm.interfacz.dao.entity.SvrNodeCodeRltExample;
import com.huitone.smspfm.interfacz.dao.entity.SvrNodeDef;
import com.huitone.smspfm.interfacz.dao.entity.SvrNodeDefExample;
import com.huitone.smspfm.interfacz.dao.entity.UserRouteRule;
import com.huitone.smspfm.interfacz.dao.entity.UserRouteRuleExample;
import com.huitone.smspfm.interfacz.logger.ExtLogger;
import com.huitone.smspfm.interfacz.model.SmsSpeedStatistics;
import com.huitone.smspfm.redis.impl.HashOpts;
import com.huitone.smspfm.redis.impl.KeyOpts;
import com.huitone.smspfm.redis.impl.ListOpts;
import com.huitone.smspfm.redis.impl.ScriptOpts;
import com.huitone.smspfm.redis.impl.SetOpts;
import com.huitone.smspfm.redis.impl.StringOpts;
import com.huitone.smspfm.redis.impl.ZsetOpts;
import com.huitone.smspfm.redis.pipeline.PipelineOpts;

/**   
* @Title StaticConfigs.java 
* @Package com.huitone.smspfm.core.config.impl 
* @Description 保存全局可用参数或者配置文件,方便程序使用以及重新加载 
* @author ybliang   
* @date 2017年5月17日 下午5:46:16 
* @version V1.0   
*/
public class AppStaticConfigs {
	
	public static RedisSerializer<String> stringRedisSerializer = new StringRedisSerializer();
	
	public static ExtLogger logger = ExtLogger.create(AppStaticConfigs.class);
	
	static {
		ContextUtils.getInstance();
	}
	
	// conf.properties
	
	/**
	 * 需要拦截的IP黑名单
	 */
	public static Set<String> blackIps = new HashSet<String>();
	
	/**
	 * 需要忽略的IP
	 */
	public static Set<String> ignoreIps = new HashSet<String>();
	
	/**
	 * 状态报告推送任务线程池大小
	 */
	public static int smspfmRptPoolSize = 1;
	
	/**
	 * 上行短信推送线程池大小
	 */
	public static int smspfmMoPoolSize = 1;
	
	/**
	 * 消息处理器的线程池大小
	 */
	public static int smspfmMhePoolSize = 1;
	
	/**
	 * 接口服务端口号
	 */
	public static int smspfmServerPort = 8901;
	
	/**
	 * 可接受的最大socket连接数
	 */
	public static int smspfmMaxSocket = 1000;
	
	/**
	 * 业务编号
	 */
	public static Long smspfmServerCode = null;
	
	/**
	 * 保存记录运行参数的hash的key
	 */
	public static String RunningParamsHashSet = null;
	
	/**
	 * 记录运行参数的hash
	 */
	public static String RunningParamsHash = null;
	/**
	 * 记录运行参数的hash
	 */
	public static byte[] RunningParamsHashB = null;
	
	/**
	 * 回执报告重发时间间隔
	 */
	public static long rptResendInterval = 60000;
	
	/**
	 * 每次读取多少条报告
	 */
	public static int rptReadPerTime = 1000;
	
	/**
	 * 每次挑出多少条超时需要重发的报告
	 */
	public static int pickoutrptPerTime = 1000;
	
	/**
	 * 上行短信重发时间间隔
	 */
	public static long moResendInterval = 60000;
	
	/**
	 * 每次读取多少条上行短信
	 */
	public static int moReadPerTime = 1000;
	
	/**
	 * 每次挑出多少条超时需要重发的上行短信
	 */
	public static int pickoutmoPerTime = 1000;
	
	/**
	 * 是否过过滤发时段短信
	 */
	public static boolean forbidtimeFilterOn = true;
	
	/**
	 * 是否过滤序列号重复短信
	 */
	public static boolean repeatseqsFilterOn = true;
	
	/**
	 * 是否开启速率统计
	 * 此为接口速率统计
	 */
	public static boolean speedStatisticsOn = false;
	
	/**
	 * 是否开启短信流量控制
	 */
	public static boolean speedControl = false;
	
	/**
	 * 本地接入短信流量表[svrNode:serviceCode:month:day:hour:minute:second]
	 */
	public static volatile Map<String,SmsSpeedStatistics>  smsSpeedMap= new ConcurrentHashMap<String, SmsSpeedStatistics>();
	
	/**
	 * 本地短信流量缓存超时清除时间
	 */
	public static int smsSpeedTimeOut = 180000;
	
	/**
	 * 短信流量统计数据线程池大小（需要开启短信流量控制）
	 */
	public static int smsSpeedPoolSize = 10;
	
	/**
	 * 短信流量线程检测间隔（需要开启短信流量控制）
	 */
	public static int smsSpeedPertime = 60000;
	
	/**
	 * 短信流量缓存数据的hash
	 */
	public static String smsSpeedCache = "SmsSpeedCache";
	
	/**
	 * 短信流量缓存数据的hash
	 */
	public static byte[] smsSpeedCacheB = null;
	
	/**
	 * 记录每秒钟速度的队列(当且仅当开启速率统计时才有效)
	 */
	public static int speedSLength = 0;
	
	/**
	 * 记录每分钟速度的队列(当且仅当开启速率统计时才有效)
	 */
	public static int speedMLength = 0;
	
	/**
	 * 是否检测服务中的客户端9901[或其它]端口是否可用
	 */
	public static boolean clientConnCheckTaskOn = true;
	
	/**
	 * 检测的时间间隔
	 */
	public static long clientConnCheckPertime = 60000;
	
	/**
	 * 同时检测多少个客户端9901[或其它]端口是否可用
	 */
	public static int clientConnCheckPoolsize = 30;
	
	/**
	 * 根据客户端的联通状态自动调整是否推送上行短信或者状态报告
	 */
	public static boolean clientDeliverAndReportAutoOnOff = false;
	
	/**
	 * 是否开启定时重载配置信息
	 */
	public static boolean reloadConfigTimingOnOff = false;
	
	/**
	 * 重载配置信息的时间间隔(单位/分钟), 只有reloadConfigTimingOnOff=true该参数才生效
	 */
	public static int reloadConfigInterval = 10;
	
	/**
	 * 黑名单用户集合[srvNode:serviceCode:user,srvNode:serviceCode:user, ...]
	 * 
	 */
	public static String configBlackListZSet = null;
	public static byte[] configBlackListZSetB = null;
	
	/**
	 * 黑名单自动扫描开关
	 */
	public static boolean smsBlackAutoMaticOnOff = false;
	/**
	 * 红名单报告监听开关
	 */
	public static boolean smsRedUserReportTaskOnOff = false;
	
	// redis1
	public static KeyOpts keyOpts = null;
	public static ZsetOpts zsetOpts = null;
	public static SetOpts setOpts = null;
	public static ListOpts listOpts = null;
	public static HashOpts hashOpts = null;
	public static StringOpts stringOpts = null;
	public static PipelineOpts pipelineOpts = null;
	public static ScriptOpts scriptOpts = null;
	
	// redis2
	public static KeyOpts keyOpts2 = null;
	public static ZsetOpts zsetOpts2 = null;
	public static SetOpts setOpts2 = null;
	public static ListOpts listOpts2 = null;
	public static HashOpts hashOpts2 = null;
	public static StringOpts stringOpts2 = null;
	public static PipelineOpts pipelineOpts2 = null;
	public static ScriptOpts scriptOpts2 = null;
	
	// redis3
	public static KeyOpts keyOpts3 = null;
	public static ZsetOpts zsetOpts3 = null;
	public static SetOpts setOpts3 = null;
	public static ListOpts listOpts3 = null;
	public static HashOpts hashOpts3 = null;
	public static StringOpts stringOpts3 = null;
	public static PipelineOpts pipelineOpts3 = null;
	public static ScriptOpts scriptOpts3 = null;
	
	
	// 数据结构的固定前缀
	public static String pSMuser = null;
	public static String pSMSuser = null;
	public static String pSMU = null;
	
	// redis数据结构start
	public static String iRptRecvSerialsZSet = null;
	public static byte[] iRptRecvSerialsZSetB = null;
	public static String iSMTempSet = null;
	
	// 平台报告
	public static String iSMNotifyList = null;
	public static byte[] iSMNotifyListB = null;
	public static String pSMNotifySerialNo = null;
	public static String iSMNotifySerialNoSet = null;
	public static byte[] iSMNotifySerialNoSetB = null;
	public static String iSMNotifyEndList = null;
	public static byte[] iSMNotifyEndListB = null;
	public static String iSMNotifyFailedList = null;
	public static byte[] iSMNotifyFailedListB = null;
	public static String iSMRptResendList = null;
	public static byte[] iSMRptResendListB = null;
	// 状态报告响应消息序号集合
	public static String iSMRptRespSerialNoZSet = null;
	
	// 上行短信
	public static String iSMMoDealList = null;
	public static byte[] iSMMoDealListB = null;
	public static String iSMMoDealSerialNoSet = null;
	public static byte[] iSMMoDealSerialNoSetB = null;
	public static String pMMoDealTmpDlvHash = null;
	public static String iSMMoEndList = null;
	public static byte[] iSMMoEndListB = null;
	public static String iSMMoDealFailedList = null;
	public static byte[] iSMMoDealFailedListB = null;
	public static String iSMMoRespSerialNoZSet = null;
	public static String iSMMoResendList = null;
	public static byte[] iSMMoResendListB = null;
	
	
	public static String pSMCacheHash = null;
	
	//红名单短信序号键值
	public static String isRedUserSmsSerial = null;
	public static byte[] isRedUserSmsSerialB = null;
	
	// redis数据结构end
	
	
	// 数据库配置信息start
	
	/**
	 * 禁发时段[srvNode:serviceCode:startTime:endTime:forbidruleId]
	 */
	//public static String forbidTimeZSet = null;
	public static Map<String, Set<String>> forbidTimeMap = new HashMap<>();
	
	/**
	 * 业务端业务编码映射关系[srvNode:serviceCode:recId]
	 */
	//public static String srvNSCodeZSet = null;
	public static Map<String,Set<String>> srvNSCodeMap = new HashMap<>();
	
	/**
	 * 错误码[errCode:errMsg:innerCode:fromType:errType:recId]
	 */
	//public static String errorCodeZSet = null;
	public static Map<String,String> errorCodeMap = new HashMap<>();
	
	/**
	 * 扩展码[srvNode:extCode:recId]
	 */
	//public static String srvNodeExtCodeZSet = null;
	public static Map<String, Set<String>> srvNodeExtCodeMap = new HashMap<>();
	/**
	 * 业务端定义信息 key=业务端号 , value=业务端定义信息
	 */
	public static Map<String, SvrNodeDef> svrNodeDefMap = new ConcurrentHashMap<>();
	
	/**
	 * [gateLinkId:gateType]
	 */
	//public static String gateTypeZSet = null;
	public static Map<String, String> gateTypeMap = new HashMap<>(); 
	
	/**
	 * [mobileCorp:[gateLinkIds]]
	 */
	public static Map<String,Set<String>> gateMobileCorpSet = new HashMap<String, Set<String>>();
	
	/**
	 * [phone:mobileCorp]
	 */
	public static Map<String,String> phoneMobileCorpMap = new HashMap<String, String>();
	
	/*
	 * 业务短信流量控制配置表
	 * [srvNode:serviceCode][limittype:flowspeed:timeunit]
	 */
	public static Map<String,Set<String>> speedControlMap = new HashMap<>();
	
	/*
	 * 短信接收编码错误定义表
	 * [gateType:codeContentS]
	 */
	public static Map<String,Set<SmsResultCodeDef>> smsResultCodeDefMap = new HashMap<String, Set<SmsResultCodeDef>>();//TODO 还未初始化

	
	// 数据库配置信息end
	
	// lua 脚本开始
	public static String luaGetRpt = null;
	public static String luaGetResendRpt = null;
	public static String luaRptRespSucc = null;
	public static String luaGetMo = null;
	public static String luaGetResendMo = null;
	public static String luaMoRespSucc = null;
	public static String luaPickOutRpt = null;
	public static String luaPickOutMo = null;
	public static String luaRptSendSucc = null;
	public static String luaMoSendSucc = null;
	public static String luaGetForbid = null;//禁发队列脚本  
	public static String luaGetPriority = null;//优先级队列脚本
	
	public static String luaGetRedUserLength = null;//红名单要处理的短信数量
	public static String luaGetRedUserList = null;//红名单短信序列号
	// lua 脚本结束
	
	//TODO
	//短信归属服务ID
	public static String smsSrvId = null;
	
	//短信平台运行标识
	public static boolean smsRuningFlag = true;
	
	//旧平台文件保存路径
	public static String smsOldFilePath = null;
	
	//旧平台文件保存目录名
	public static String smsOldFileName = null;
	
	//平台切换后线程池大小
	public static int platformSwitchPoolSize  = 10;
	
	/**
	 * 禁发队列的键值
	 */
	public static String iSMForbidZSet = null;
	public static byte[] iSMForbidZSetB = null;
	
	/**
	 * 优先级队列键值
	 */
	public static String isMPriorityList = null;
	
	/**
	 * 每次最多从禁发队列中取mtfbdBatchSizePerTime条记录
	 */
	public static int mtfbdBatchSizePerTime = 1000;
	
	/**
	 * 红名单列表
	 */
	public static Map<String,ReduserList> redUserMap = new HashMap<String, ReduserList>();
	
	//红名单报告文件保存路径
	public static String redUserFilePath = null;
		
	//红名单报告文件保存目录名
	public static String redUserFileName = null;
	
	/**
	 * 2048/70=29条;
	 * 接入平台的长短信内容最大值
	 */
	public static int smsContentMaxLength = 3096; 
	
	/**
	 * 初始化静态参数
	 */
	public static void init() {
		initProperties();
		initRedisDataStructure();
		initRedisOpts();
		initOracleConfig2();
		initLuaScript();
//		initLocalSupport();
	}
	
	

	public static void reload() {
		
		init();
//		Runtime.getRuntime().gc();//不可靠　静态变量会过滤
		//检查平台是否切换
	}
	
//	private static void initLocalSupport() {
//		
//		if(fileManage == null || fileManage.getOldSmsWriter() == null){
//			fileManage = FileWriterManage.getInstance();
//			fileManage.initOldSmsFileWriter(smsOldFilePath, smsOldFileName);
//		}
//		
//		
//	}
	
	private static void initProperties() {
		smspfmServerCode = StringUtils.toLongP(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.code")), 100001);
		smspfmMaxSocket = StringUtils.toInteger(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.connect.maxActive")), 1000, true);
		smspfmServerPort = StringUtils.toInteger(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.port")), 8901, true);
		smspfmMhePoolSize = StringUtils.toInteger(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.handler.poolsize")), 1000, true);
		smspfmRptPoolSize = StringUtils.toInteger(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.report.poolsize")), 10, true);
		smspfmMoPoolSize = StringUtils.toInteger(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.deliver.poolsize")), 10, true);
		reloadConfigTimingOnOff = StringUtils.equals("on", StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.reload.config.timing")));
		reloadConfigInterval = StringUtils.toInteger(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.reload.config.interval")), 10, true);
		smsSrvId = StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.srv.id"));
		smsOldFilePath = StringUtils.trim(ContextPropertiesUtils.getProperty("old.sms.file.old.send.path"));
		smsOldFileName = StringUtils.trim(ContextPropertiesUtils.getProperty("old.sms.file.old.send.name"));
		
		redUserFilePath = StringUtils.trim(ContextPropertiesUtils.getProperty("old.sms.file.report.path"));
		redUserFileName = StringUtils.trim(ContextPropertiesUtils.getProperty("old.sms.file.report.name"));
		
		configBlackListZSet = ContextPropertiesUtils.getProperty("zset.blacklist.rule");
		configBlackListZSetB = stringRedisSerializer.serialize(configBlackListZSet);
		
		iSMForbidZSet = ContextPropertiesUtils.getProperty("SMForbidZSet");
		iSMForbidZSetB = stringRedisSerializer.serialize(iSMForbidZSet); 
		
		isMPriorityList = ContextPropertiesUtils.getProperty("SMPriorityList");
		isRedUserSmsSerial = ContextPropertiesUtils.getProperty("SMRedUserSerial");
		isRedUserSmsSerialB = AppStaticConfigs.stringRedisSerializer.serialize(isRedUserSmsSerial);
		String[] bips = StringUtils.split(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.blackl.ips")), ",");
		String[] iips = StringUtils.split(StringUtils.trim(ContextPropertiesUtils.getProperty("smspfm.server.ignore.ips")), ",");
		
		if (bips != null) {
			for (int i = 0 ; i < bips.length ; i ++) {
				String ip = bips[i];
				if (StringUtils.isIPv4(ip)) {
					blackIps.add(ip);
				}
			}
		}
		
		if (iips != null) {
			for (int i = 0 ; i < iips.length ; i ++) {
				String ip = iips[i];
				if (StringUtils.isIPv4(ip)) {
					ignoreIps.add(ip);
				}
			}
		}
		
		smsBlackAutoMaticOnOff = StringUtils.equals("on", StringUtils.trim(ContextPropertiesUtils.getProperty("sms.black.auto.matic.task")));
		smsRedUserReportTaskOnOff = StringUtils.equals("on", StringUtils.trim(ContextPropertiesUtils.getProperty("sms.reduser.report.task")));
	}
	
	private static void initLuaScript() {
		
		boolean isWindows = System.getProperty("os.name").indexOf("Window") >= 0;
		
		// 读取报告luaGetRpt
		StringBuffer bufferGetRpt = null;
		if(isWindows){
			try {
				bufferGetRpt = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/getrpt.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			bufferGetRpt = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/getrpt.lua"));
		}
		if (bufferGetRpt != null) {
			luaGetRpt = bufferGetRpt.toString();
		}
		
		// 获取需要重发的报告
		StringBuffer stringBuffer1 = null;
		if(isWindows){
			try {
				stringBuffer1 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/getresendrpt.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer1 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/getresendrpt.lua"));
		}
		if (stringBuffer1 != null) {
			luaGetResendRpt = stringBuffer1.toString();
		}
		
		// 收到回执报告响应后的操作,将报告状态设置为成功发送
		StringBuffer stringBuffer2 = null;
		if(isWindows){
			try {
				stringBuffer2 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/rptrespsucc.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer2 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/rptrespsucc.lua"));
		}
		if (stringBuffer2 != null) {
			luaRptRespSucc = stringBuffer2.toString();
		}
		
		// 读取上行短信luaGetMo
		StringBuffer bufferGetMo = null;
		if(isWindows){
			try {
				bufferGetMo = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/getmo.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			bufferGetMo = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/getmo.lua"));
		}
		if (bufferGetMo != null) {
			luaGetMo = bufferGetMo.toString();
		}
		
		// 读取需要重发的上行短信
		StringBuffer stringBuffer3 = null;
		if(isWindows){
			try {
				stringBuffer3 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/getresendmo.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer3 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/getresendmo.lua"));
		}
		if (stringBuffer3 != null) {
			luaGetResendMo = stringBuffer3.toString();
		}
		
		// 上行短信推送成功后设置为成功
		StringBuffer stringBuffer4 = null;
		if(isWindows){
			try {
				stringBuffer4 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/morespsucc.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer4 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/morespsucc.lua"));
		}
		if (stringBuffer4 != null) {
			luaMoRespSucc = stringBuffer4.toString();
		}
		
		// 从集合中挑选出超时未收到客户端响应需要重发的状态报告
		StringBuffer stringBuffer5 = null;
		if(isWindows){
			try {
				stringBuffer5 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/pickoutrpt.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer5 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/pickoutrpt.lua"));
		}
		if (stringBuffer5 != null) {
			luaPickOutRpt = stringBuffer5.toString();
		}
		
		// luaPickOutMo
		StringBuffer stringBuffer6 = null;
		if(isWindows){
			try {
				stringBuffer6 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/pickoutmo.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer6 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/pickoutmo.lua"));
		}
		if (stringBuffer6 != null) {
			luaPickOutMo = stringBuffer6.toString();
		}
		
		//luaRptSendSucc
		StringBuffer stringBuffer7 = null;
		if(isWindows){
			try {
				stringBuffer7 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/rptsendsucc.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer7 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/rptsendsucc.lua"));
		}
		if (stringBuffer7 != null) {
			luaRptSendSucc = stringBuffer7.toString();
		}
		
		// luaMoSendSucc
		StringBuffer stringBuffer8 = null;
		if(isWindows){
			try {
				stringBuffer8 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/mosendsucc.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer8 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/mosendsucc.lua"));
		}
		if (stringBuffer8 != null) {
			luaMoSendSucc = stringBuffer8.toString();
		}
		
		//luaforbid
		StringBuffer stringBuffer9 = null;
		if(isWindows){
			try {
				stringBuffer9 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader().getResource("lua/getforbid.lua").getPath().substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e){
				logger.error("lua script config load error !!");
			} 
		} else {
			stringBuffer9 = FileUtils.read(AppStaticConfigs.class.getClassLoader().getResourceAsStream("lua/getforbid.lua"));
		}
		if (stringBuffer9 != null) {
			luaGetForbid = stringBuffer9.toString();
		}
		
		// luaPriority
		StringBuffer stringBuffer10 = null;
		if (isWindows) {
			try {
				stringBuffer10 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader()
								.getResource("lua/getpriority.lua").getPath()
								.substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			}
		} else {
			stringBuffer10 = FileUtils.read(AppStaticConfigs.class
					.getClassLoader().getResourceAsStream("lua/getpriority.lua"));
		}
		if (stringBuffer10 != null) {
			luaGetPriority = stringBuffer10.toString();
		}
		
		
		StringBuffer stringBuffer11 = null;
		if (isWindows) {
			try {
				stringBuffer11 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader()
								.getResource("lua/getreduserLength.lua").getPath()
								.substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			}
		} else {
			stringBuffer11 = FileUtils.read(AppStaticConfigs.class
					.getClassLoader().getResourceAsStream("lua/getreduserLength.lua"));
		}
		if (stringBuffer11 != null) {
			luaGetRedUserLength = stringBuffer11.toString();
		}
		
		StringBuffer stringBuffer12 = null;
		if (isWindows) {
			try {
				stringBuffer12 = FileUtils.read(new FileInputStream(
						AppStaticConfigs.class.getClassLoader()
								.getResource("lua/getreduserList.lua").getPath()
								.substring(1).replace("/", "\\\\")));
			} catch (FileNotFoundException e) {
				logger.error("lua script config load error !!");
			}
		} else {
			stringBuffer12 = FileUtils.read(AppStaticConfigs.class
					.getClassLoader().getResourceAsStream("lua/getreduserList.lua"));
		}
		if (stringBuffer12 != null) {
			luaGetRedUserList = stringBuffer12.toString();
		}

	}
	
	/**
	 * 初始化Redis的数据结构名
	 */
	private static void initRedisDataStructure() {
		
		rptReadPerTime		 = StringUtils.toInteger(ContextPropertiesUtils.getProperty("smspfm.server.report.read.pertime"), 1000, true);
		moReadPerTime 		= StringUtils.toInteger(ContextPropertiesUtils.getProperty("smspfm.server.deliver.read.pertime"), 1000, true);
		
		speedControl			= "on".equals(ContextPropertiesUtils.getProperty("smspfm.server.speed.control"));
		speedStatisticsOn 	= "on".equals(ContextPropertiesUtils.getProperty("smspfm.speed.statistics"));
		forbidtimeFilterOn 	= "on".equals(ContextPropertiesUtils.getProperty("smspfm.forbidtime.filter"));
		repeatseqsFilterOn 	= "on".equals(ContextPropertiesUtils.getProperty("smspfm.repeatseqs.filter"));
		clientDeliverAndReportAutoOnOff = "on".equals(ContextPropertiesUtils.getProperty("smspfm.client.dr.auto.onoff"));
		clientConnCheckTaskOn = "on".equals(ContextPropertiesUtils.getProperty("smspfm.client.conn.check.task"));
		clientConnCheckPoolsize = StringUtils.toInteger(ContextPropertiesUtils.getProperty("smspfm.client.conn.check.poolsize"), 30, true);
		clientConnCheckPertime = StringUtils.toInteger(ContextPropertiesUtils.getProperty("smspfm.client.conn.check.pertime"), 60000, true);
		
		speedSLength = StringUtils.strToInt(ContextPropertiesUtils.getProperty("smspfm.speed.s.length"), 3600);
		speedMLength = StringUtils.strToInt(ContextPropertiesUtils.getProperty("smspfm.speed.m.length"), 1440);
		
		//forbidTimeZSet = ContextPropertiesUtils.getProperty("zset.forbid.time.rule");
		//srvNSCodeZSet = ContextPropertiesUtils.getProperty("zset.srvnscode.rule");
		//errorCodeZSet = ContextPropertiesUtils.getProperty("zset.error.code.mng");
		//srvNodeExtCodeZSet = ContextPropertiesUtils.getProperty("zset.srvnode.extcode");
		//gateTypeZSet = ContextPropertiesUtils.getProperty("zset.gatetype"); 
		
		iRptRecvSerialsZSet = ContextPropertiesUtils.getProperty("zset.recv.serials"); 
		iSMTempSet = ContextPropertiesUtils.getProperty("SMTempSet");
		iSMMoEndList = ContextPropertiesUtils.getProperty("SMMoEndList");
		iSMMoEndListB = stringRedisSerializer.serialize(iSMMoEndList);
		
		iSMNotifyList = ContextPropertiesUtils.getProperty("SMNotifyList");
		iSMNotifyListB = stringRedisSerializer.serialize(iSMNotifyList);
		
		pSMCacheHash = ContextPropertiesUtils.getProperty("SMCacheHashPrefix");
		pSMNotifySerialNo = ContextPropertiesUtils.getProperty("SMNotifySerialNoPrefix");
		iSMNotifySerialNoSet = ContextPropertiesUtils.getProperty("SMNotifySerialNoSet");
		iSMNotifySerialNoSetB = stringRedisSerializer.serialize(iSMNotifySerialNoSet);
		iSMNotifyEndList = ContextPropertiesUtils.getProperty("SMNotifyEndList");
		iSMNotifyEndListB = stringRedisSerializer.serialize(iSMNotifyEndList);
		iSMNotifyFailedList = ContextPropertiesUtils.getProperty("SMNotifyFailedList");
		iSMNotifyFailedListB = stringRedisSerializer.serialize(iSMNotifyFailedList);
		
		iSMMoDealList = ContextPropertiesUtils.getProperty("SMMoDealList"); 
		iSMMoDealListB = stringRedisSerializer.serialize(iSMMoDealList);
		iSMMoDealSerialNoSet = ContextPropertiesUtils.getProperty("SMMoDealSerialNoSet");
		iSMMoDealSerialNoSetB = stringRedisSerializer.serialize(iSMMoDealSerialNoSet);
		pMMoDealTmpDlvHash = ContextPropertiesUtils.getProperty("SMMoDealTmpDlvHashPrefix");
		iSMMoDealFailedList = ContextPropertiesUtils.getProperty("SMMoDealFailedList");
		iSMMoDealFailedListB = stringRedisSerializer.serialize(iSMMoDealFailedList);
		
		iSMRptRespSerialNoZSet = ContextPropertiesUtils.getProperty("SMRptRespSerialNoZSet");
		iSMMoRespSerialNoZSet = ContextPropertiesUtils.getProperty("SMMoRespSerialNoZSet");
		
		iSMRptResendList = ContextPropertiesUtils.getProperty("SMRptResendList");
		iSMRptResendListB = stringRedisSerializer.serialize(iSMRptResendList);
		
		iSMMoResendList = ContextPropertiesUtils.getProperty("SMMoResendList");
		iSMMoResendListB = stringRedisSerializer.serialize(iSMMoResendList);
		
		//固定的数据结构前缀
		pSMuser = ContextPropertiesUtils.getProperty("SMuser");
		pSMSuser = ContextPropertiesUtils.getProperty("SMSuser");
		pSMU = ContextPropertiesUtils.getProperty("SMU");
		
		iRptRecvSerialsZSetB = stringRedisSerializer.serialize(iRptRecvSerialsZSet);
		
		RunningParamsHashSet = ContextPropertiesUtils.getProperty("RunningParamsHashSet");
		RunningParamsHash = ContextPropertiesUtils.getProperty("RunningParamsHashPrefix") + ":" + smspfmServerCode;
		RunningParamsHashB = stringRedisSerializer.serialize(RunningParamsHash);
		
		smsSpeedCacheB = stringRedisSerializer.serialize(smsSpeedCache);
		
		
	}
	
	/**
	 * 初始化redis操作类
	 */
	private static void initRedisOpts() {
		
		initRedisOpts1();
		
		initRedisOpts2();
		
		initRedisOpts3();
	}



	public static void initRedisOpts3() {
		keyOpts3 = (KeyOpts) ContextUtils.getBean2("keyOpts3");
		zsetOpts3 = (ZsetOpts) ContextUtils.getBean2("zsetOpts3"); 
		setOpts3 = (SetOpts) ContextUtils.getBean2("setOpts3");
		listOpts3 = (ListOpts) ContextUtils.getBean2("listOpts3");
		hashOpts3 = (HashOpts) ContextUtils.getBean2("hashOpts3");
		stringOpts3 = (StringOpts) ContextUtils.getBean2("stringOpts3");
		pipelineOpts3 = (PipelineOpts) ContextUtils.getBean2("pipelineOpts3");
		scriptOpts3 = (ScriptOpts) ContextUtils.getBean2("scriptOpts3");
	}



	public static void initRedisOpts2() {
		keyOpts2 = (KeyOpts) ContextUtils.getBean2("keyOpts2");
		zsetOpts2 = (ZsetOpts) ContextUtils.getBean2("zsetOpts2"); 
		setOpts2 = (SetOpts) ContextUtils.getBean2("setOpts2");
		listOpts2 = (ListOpts) ContextUtils.getBean2("listOpts2");
		hashOpts2 = (HashOpts) ContextUtils.getBean2("hashOpts2");
		stringOpts2 = (StringOpts) ContextUtils.getBean2("stringOpts2");
		pipelineOpts2 = (PipelineOpts) ContextUtils.getBean2("pipelineOpts2");
		scriptOpts2 = (ScriptOpts) ContextUtils.getBean2("scriptOpts2");
	}



	public static void initRedisOpts1() {
		keyOpts = (KeyOpts) ContextUtils.getBean2("keyOpts");
		zsetOpts = (ZsetOpts) ContextUtils.getBean2("zsetOpts"); 
		setOpts = (SetOpts) ContextUtils.getBean2("setOpts");
		listOpts = (ListOpts) ContextUtils.getBean2("listOpts");
		hashOpts = (HashOpts) ContextUtils.getBean2("hashOpts");
		stringOpts = (StringOpts) ContextUtils.getBean2("stringOpts");
		pipelineOpts = (PipelineOpts) ContextUtils.getBean2("pipelineOpts");
		scriptOpts = (ScriptOpts) ContextUtils.getBean2("scriptOpts");
	}
	
	private static void initOracleConfig2() {
		
		//加载客户接收短信编码表
		Map<String,Set<SmsResultCodeDef>> smsResultCodeDefMapTmp = new HashMap<String, Set<SmsResultCodeDef>>();
		SmsResultCodeDefExample  smsResultCodeDefExample = new SmsResultCodeDefExample();
		smsResultCodeDefExample.createCriteria().andStatusEqualTo("1");
		List<SmsResultCodeDef> smsResultCodeDefLists = ContextUtils.getBean2(SmsResultCodeDefMapper.class).selectByExample(smsResultCodeDefExample);
		for(int i = 0; i < smsResultCodeDefLists.size() ; i++ ){
			SmsResultCodeDef smsResultCodeDef = smsResultCodeDefLists.get(i);
			String gateType = smsResultCodeDef.getGateType();
			String codeType = smsResultCodeDef.getCodeType();
			Set<SmsResultCodeDef> set = smsResultCodeDefMapTmp.get(codeType);
			if(StringUtils.isEmpty(set)){
				set = new HashSet<SmsResultCodeDef>();
				smsResultCodeDefMapTmp.put(codeType, set);
			}
			set.add(smsResultCodeDef);
		}
		smsResultCodeDefMap = smsResultCodeDefMapTmp;
		
		
		//加载红名单
		Map<String,ReduserList> reduserListTmp = new HashMap<String, ReduserList>();
		ReduserListExample reduserListExample = new ReduserListExample();
		reduserListExample.createCriteria().andStatusEqualTo("1");
		List<ReduserList> reduserLists = ContextUtils.getBean2(ReduserListMapper.class).selectByExample(reduserListExample);
		for(int i  = 0 ; i < reduserLists.size(); i++){
			ReduserList r = reduserLists.get(i);
			String phone = r.getPhone();
			if(! StringUtils.isEmpty(phone)){
				reduserListTmp.put(phone, r);
			}
		}
		redUserMap = reduserListTmp;
		
		//加载服务定义表
		PlatformServerExample platformServerExample = new PlatformServerExample();
		platformServerExample.setDistinct(true);
		platformServerExample.createCriteria().andSmSrvIdEqualTo(smsSrvId).andStatusEqualTo("1");		
		List<PlatformServer> platformServers = ContextUtils.getBean2(PlatformServerMapper.class).selectByExample(platformServerExample);
		for(PlatformServer ps : platformServers){
			String mySmsSrvId = ps.getSmSrvId();
			String myRuningFlag = ps.getRuningflag();
			if(StringUtils.equals(smsSrvId, mySmsSrvId)){
				smsRuningFlag = StringUtils.equals("1", myRuningFlag);
				break;
			}
		}
		
		//加载流量控制规则
		Map<String, Set<String>> speedControlMapTmp = new HashMap<>();
		SpeedControlExample speedControlExample = new SpeedControlExample();
		speedControlExample.createCriteria().andStatusEqualTo("1");
//		speedControlExample.createCriteria();
		List<SpeedControl> speedControls = ContextUtils.getBean2(SpeedControlMapper.class).selectByExample(speedControlExample);
		for(SpeedControl sc : speedControls){
			String srvNode = StringUtils.toString(sc.getSvrNode());
//			String serviceCode = StringUtils.toString(sc.getServiceCode());
			String limittype = StringUtils.toString(sc.getLimittype());
			int flowspeed = sc.getFlowspeed();
			if (flowspeed != 0) {
				String timeunit = StringUtils.toString(sc.getTimeunit());

				if (StringUtils.isEmpty(srvNode)) {
					srvNode = "*";
				}
				String key = srvNode;
				Set<String> set = speedControlMapTmp.get(key);
				if (StringUtils.isEmpty(set)) {
					set = new HashSet<String>();
					speedControlMapTmp.put(key, set);
				}
				set.add(limittype + ":" + StringUtils.toString(flowspeed) + ":"
						+ timeunit);
			}
		}
		speedControlMap = speedControlMapTmp;
		
		// 加载禁发时段过滤规则
		Map<String, Set<String>> forbidTimeMapTmp = new HashMap<>();
		ForbidRuleExample forbidRuleExample = new ForbidRuleExample();
		forbidRuleExample.createCriteria().andStatusEqualTo("1");
		List<ForbidRule> forbids = ContextUtils.getBean2(ForbidRuleMapper.class).selectByExample(forbidRuleExample);
		for (ForbidRule forbid:forbids) {
			
			String srvNode = StringUtils.toString(forbid.getSvrNode());
			String serviceCode = StringUtils.toString(forbid.getServiceCode());
			Float startTime = forbid.getStartTime();
			Float endTime = forbid.getEndTime();
			
			String key = srvNode + ":" + serviceCode;
			Set<String> set = forbidTimeMapTmp.get(key);
			if (set == null) {
				set = new HashSet<>();
				set.add(startTime + ":" + endTime);
				forbidTimeMapTmp.put(key, set);
			} else {
				set.add(startTime + ":" + endTime);
			}
		}
		forbidTimeMap = forbidTimeMapTmp;
		
		// 加载业务端业务编码关系表
		Map<String,Set<String>> srvNSCodeMapTmp = new HashMap<>();
		SvrNodeCodeRltExample svrNodeCodeRltExample = new SvrNodeCodeRltExample();
		svrNodeCodeRltExample.createCriteria().andStatusEqualTo("1");
		List<SvrNodeCodeRlt> sncr = ContextUtils.getBean2(SvrNodeCodeRltMapper.class).selectByExample(svrNodeCodeRltExample);
		for (SvrNodeCodeRlt s:sncr) {
			
			String svrNode = StringUtils.toString(s.getSvrNode());
			String serviceCode = StringUtils.toString(s.getServiceCode());
			
			Set<String> set = srvNSCodeMapTmp.get(svrNode);
			if (set == null) {
				set = new HashSet<>();
				set.add(serviceCode);
				srvNSCodeMapTmp.put(svrNode, set);
			} else {
				set.add(serviceCode);
			}
//			System.out.println(svrNode+"  :   "+serviceCode);
		}
		srvNSCodeMap = srvNSCodeMapTmp;
		
		// 加载错误码
		//errorCodeMap.clear();
		StringBuffer buffer = new StringBuffer();
		Map<String,String> errorCodeMapTmp = new HashMap<>();
		ErrorMngExample errorMngExample = new ErrorMngExample();
		errorMngExample.createCriteria().andStatusEqualTo("1");
		List<ErrorMng> errorList = ContextUtils.getBean2(ErrorMngMapper.class).selectByExample(errorMngExample);
		for (ErrorMng error:errorList) {
			buffer.setLength(0);
			
			String errCode = StringUtils.escapeColon(error.getErrCode());
			String fromType = StringUtils.lowerCase(error.getFromType());
			
			buffer.append(errCode);
			buffer.append(":");
			buffer.append(StringUtils.escapeColon(error.getErrMsg()));
			buffer.append(":");
			buffer.append(StringUtils.toString(error.getInnerCode()));
			buffer.append(":");
			buffer.append(fromType);
			buffer.append(":");
			buffer.append(error.getErrType());
			buffer.append(":");
			buffer.append(error.getRecId());
			
			errorCodeMapTmp.put(fromType + ":" + errCode, buffer.toString());
		}
		errorCodeMap = errorCodeMapTmp;
		
		// 加载业务端定义表
		Map<String, Set<String>> srvNodeExtCodeMapTmp = new HashMap<>();
		Map<String, SvrNodeDef> svrNodeDefMapTmp = new ConcurrentHashMap<>();
		SvrNodeDefExample svrNodeDefExample = new SvrNodeDefExample();
		svrNodeDefExample.createCriteria().andStatusEqualTo("1");
		List<SvrNodeDef> snd = ContextUtils.getBean2(SvrNodeDefMapper.class).selectByExample(svrNodeDefExample);
		for (SvrNodeDef s:snd) {
			
			String srvNode = StringUtils.toString(s.getSvrNode());
			String sendPort = StringUtils.toString(s.getSendPort());
			String whiteUser = StringUtils.toString(s.getSrvtype());
			
			svrNodeDefMapTmp.put(srvNode, s);
			
			Set<String> set = srvNodeExtCodeMapTmp.get(srvNode);
			if (set == null) {
				set = new HashSet<>();
				set.add(sendPort);
				srvNodeExtCodeMapTmp.put(srvNode, set);
			} else {
				set.add(sendPort);
			}
		}
		svrNodeDefMap = svrNodeDefMapTmp;

		
		// 加载业务端匹配表
		MoInsExample moInsExample = new MoInsExample();
		moInsExample.createCriteria().andStatusEqualTo("1");
		List<MoIns> moInses = ContextUtils.getBean2(MoInsMapper.class).selectByExample(moInsExample);
		for (MoIns moIns:moInses) {
			String svrNode = moIns.getSvrNode();
			String sendport = moIns.getSendport();
			if (!StringUtils.isEmpty(svrNode)) {
				Set<String> set = srvNodeExtCodeMapTmp.get(svrNode);
				if (set == null) {
					set = new HashSet<>();
					set.add(sendport);
					srvNodeExtCodeMapTmp.put(svrNode, set);
				} else {
					set.add(sendport);
				}
			}
		}
		srvNodeExtCodeMap = srvNodeExtCodeMapTmp;
		
		// 加载网关定义表
		Map<String, String> gateTypeMapTmp = new HashMap<>();
		Map<String,Set<String>> gateMobileCorpSetTmp = new HashMap<String, Set<String>>();
		GateDefExample gateDefExample = new GateDefExample();
		gateDefExample.createCriteria().andStatusEqualTo("1");
		List<GateDef> gds = ContextUtils.getBean2(GateDefMapper.class).selectByExample(gateDefExample);
		for (GateDef gd:gds) {
			
			String gateLinkId = StringUtils.toString(gd.getGateLinkId());
			String gateType = StringUtils.toString(gd.getGateType());
			String gateMobileCorp = gd.getMobilecorp();
			gateTypeMapTmp.put(gateLinkId, gateType);
			Set<String> set = null;
			if(gateMobileCorpSetTmp.containsKey(gateMobileCorp)){
				set = gateMobileCorpSetTmp.get(gateMobileCorp);
			} else {
				set = new HashSet<String>();
				gateMobileCorpSetTmp.put(gateMobileCorp, set);
			}
			set.add(gateLinkId);
			
		}
		gateTypeMap = gateTypeMapTmp;
		gateMobileCorpSet = gateMobileCorpSetTmp;
		
		//加载号段路由表
		Map<String, String> phoneMobileCorpTmp = new HashMap<>();
		UserRouteRuleExample userRouteRuleExample = new UserRouteRuleExample();
		userRouteRuleExample.createCriteria().andStatusEqualTo("1");		
		List<UserRouteRule> userRouteRuleList = ContextUtils.getBean2(UserRouteRuleMapper.class).selectByExample(userRouteRuleExample);
		for(UserRouteRule userRouteRule : userRouteRuleList){
			String phone = userRouteRule.getSectionNo();
			String mobileCorp = userRouteRule.getMobilCorp();
			if(!StringUtils.isEmpty(phone) && !StringUtils.isEmpty(mobileCorp)){
				phoneMobileCorpTmp.put(phone, mobileCorp);
			}
		}
		phoneMobileCorpMap = phoneMobileCorpTmp;
		
		// 保存运行参数Hash的key到集合RunningParamsHashSet
		setOpts.add(RunningParamsHashSet, RunningParamsHash);
	}
}
